package com.hundsun.s3.mrs.pub.utils;

import java.io.File;
import java.util.Iterator;
import java.util.List;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.junit.Test;

public class JunitTest {
	@Test
	public void t1() throws DocumentException {
		File file = new File(this.getClass().getClassLoader()
				.getResource("message-type2handle.xml").getPath());
		SAXReader reader = new SAXReader();
		Document doc = reader.read(file);
		Element rootElement = doc.getRootElement();
		@SuppressWarnings("unchecked")
		List<Element> kinds = rootElement.elements("kind");
		Iterator<Element> ikinds = kinds.iterator();
		while(ikinds.hasNext()) {
			Element kind = ikinds.next();
			@SuppressWarnings("unchecked")
			List<Element> mapper = kind.elements("mapper");
			Iterator<Element> iterator = mapper.iterator();
			while(iterator.hasNext()) {
				Element e = iterator.next();
				System.out.println("mapper:" + e.elementText("type") + "==>" + e.elementText("handle") );
			}
		}
	}
	
	@Test
	public void t2() {
/*		FileFilter  wff = new WildcardFileFilter("*-type2handler.xml");
		File dir = new File(FileUtils.class.getClass().getClassLoader()
				.getResource("./").getPath());
		System.out.println(dir.exists());*/
		System.out.println(Thread.currentThread().getContextClassLoader().getResource("./").getPath());
	}

}
